import  axios from 'axios'
import { Message } from 'element-ui'
import store from '@/store';

const uploader=axios.create({
	baseURL:''
});

//请求拦截
uploader.interceptors.request.use(
  config=>{
	  config.headers["Content-Type"]="multipart/form-data;charset=UTF-8";
	  config.headers["token"]="abc34234234234234";
	  console.log(store.state.token);
	  return config;
  },
  error=>{
	  
	  return Promise.reject(error);
  }
)

//响应拦截
uploader.interceptors.response.use(
	response=>{
		console.log("响应",response);
	   return response;
	},
	error=>{
		if(error.status===404){
			Message({
			  message: "服务器内部错误!",
			  type: 'error',
			  duration: 5000
			})
		}
	   return Promise.reject(error);
	}
)

export default uploader;
 